<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../../public/css/monokai_sublime.min.css">
    <link rel="stylesheet" href="../../public/css/heightlength.css">
    <link rel="stylesheet" href="../../public/css/mxjs.css">
    <link rel="stylesheet" href="../../public/css/prism.css">
    <script src="../../public/js/jquery.js"></script>
    <script src="../../public/js/highlight.min.js"></script>
    <script src="../../public/js/prism.js"></script>
    <script src="../../public/js/clipboard.min.js"></script>

</head>
<body>

<div class="container">
    <div class="jsbg">
        <div class="col-lg-12 mxlength">
            <div class="mx-1">
                <h2>遍历数组的方式</h2>
               <code>
                    let arr=[{name:1,age:2},{name:2,age:3}];
                arr.forEach((item,index,array)=>{
                console.log(item) //1，2，3
                })
               </code>
            </div>
        </div>
        <div class="col-lg-12  ">
      <pre class="mScroll">
        <code class="lang-javascript">
       let arr=['1','2','3'];
    for(let i of arr){
        console.log(i) //1，2，3
    }
    for(let i in arr){
        console.log(arr[i]) //1，2，3
    }
    for(let i=0;i< arr.length;i++) {
        console.log(arr[i]) //1，2，3
    }
    arr.forEach((item,index,array)=>{
        console.log(item) //1，2，3
    })
    arr.map(function(value,index,array){
        console.log(value) //1，2，3
    })
    arr.filter(function(value,index,array){
        console.log(value) //1，2，3
    })
    arr.every(function(value,index,array){
        console.log(value) //1，2，3
    })
    arr.some(function(value,index,array){
        console.log(value) //1，2，3
    })
      arr.reduce(function(value,index,array){
    console.log(value) //1，2，3
    });
arr.reduceRight(function (preValue,curValue,index,array) {
    return preValue + curValue;
});
		</code>
    </pre>
        </div>
    </div>
</div>
<script>

    window.onload = function () {

        var clipboard = new Clipboard('.toolbar-item');

        clipboard.on('success', function (e) {
            console.log(e.text);
        });

        clipboard.on('error', function (e) {
            console.log(e);
        });
        $(".toolbar-item").html("<span>复制</span>")
    }
</script>
</body>
</html>
